package logic

import (
	"svvenus/conf"
	"svvenus/znet/zpb"
)

func PcAward2PbAward(award conf.PcAward) *zpb.PbAward {
	info := &zpb.PbAward{}
	info.Type = int32(award.Type)
	info.ConfigId = int32(award.ConfigId)
	info.Count = award.Count
	return info
}

func PbAward2PcAward(award *zpb.PbAward) conf.PcAward {
	info := conf.PcAward{}
	info.Type = int(award.Type)
	info.ConfigId = int(award.ConfigId)
	info.Count = award.Count
	return info
}

// SendAward
// @Description: 发送奖励
// @receiver player
// @param award
// @param sor
// @return bool
func (player *Player) SendAward(award conf.PcAward, sor zpb.RecSource) bool {
	switch award.Type {
	case conf.EAwardType货币:
		player.MoneyAdd(award.ConfigId, award.Count, sor)
	case conf.EAwardType道具:
		player.ItemAdd(award.ConfigId, award.Count, sor)
	case conf.EAwardType装备:
		for i := 0; i < int(award.Count); i++ {
			player.EquipAdd(award.ConfigId, sor)
		}
	}
	return true
}
func (player *Player) SendAwards(awards []conf.PcAward, sor zpb.RecSource) bool {
	for _, v := range awards {
		player.SendAward(v, sor)
	}
	return true
}
